package com.yang.libs.datasource

import com.xxx.lib.net.helper.RxThreadHelper
import com.xxx.lib.net.observer.XxBaseHttpObserver
import com.yang.libs.api.AppApi
import com.yang.libs.bean.MainBean

/**
 * 远程数据资源
 */
object RemoteDataSource {

    fun getMainData(baseHttpObserver: XxBaseHttpObserver<MainBean>) {
        AppApi.api.getMainData().compose(RxThreadHelper.ioAndMain())
            .doOnSubscribe { baseHttpObserver.onShowLoadingDialog() }
            .doOnNext { baseHttpObserver.onDismissLoadingDialog() }
            .doOnError { baseHttpObserver.onDismissLoadingDialog() }
            .subscribe(baseHttpObserver)
    }
}